package models

import (
	"time"
	"github.com/astaxie/beego/orm"
)

type UserDevicePoint struct {
	Id             int64
	UserId         int       `ht:"list;search;name(积分得主编号)"`
	DeviceId       int       `ht:"list;name(设备编号)"`
	Position       int       `ht:"list;name(地点编号)"`
	Point          int       `ht:"list;name(积分值)"`
	PointType      int       `ht:"list;name(获奖类型)" orm:"default(0)"`
	GetTime        time.Time `ht:"list;name(获取积分时间)"`
	LoseEffectTime time.Time `ht:"list;name(积分失效时间，预留)"`
}

func init() {
	orm.RegisterModel(new(UserDevicePoint))
}
func (*UserDevicePoint) TableName() string {
	return "user_device_point"
}

func (*UserDevicePoint) FN_Id() string {
	return "Id"
}
func (*UserDevicePoint) FN_UserId() string {
	return "UserId"
}
func (*UserDevicePoint) FN_DeviceId() string {
	return "DeviceId"
}
func (*UserDevicePoint) FN_Position() string {
	return "Position"
}
func (*UserDevicePoint) FN_Point() string {
	return "Point"
}
func (*UserDevicePoint) FN_GetTime() string {
	return "GetTime"
}
func (*UserDevicePoint) FN_LoseEffectTime() string {
	return "LoseEffectTime"
}

func UserDevicePointInsert(devicepoint *UserDevicePoint) error {
	o := orm.NewOrm()
	_, err := o.Insert(devicepoint)
	return err
}
